/**
  ******************************************************************************
  * @file    USART_app.h
  * @author  Thongnh
  * @version V1.0
  * @date    18-07-2011
  * @brief   Main process of USART
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, XICUTELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 Xicutelectronics</center></h2>
  ******************************************************************************
  */ 

#include "includes.h"

#define USE_LED

#ifndef __LED_H__
#define __LED_H__

#ifdef USE_LED


#define LED_OFF             GPIOA->BSRR  = (1<<1)
#define LED_ON              GPIOA->BRR = (1<<1)
#define LED_INV             if ((GPIOA->IDR & (1<<1))==0) LED_OFF; else LED_ON

#define INIT_LED            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);   \
                            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;               \
                            GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;       \
                            GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;        \
                            GPIO_Init(GPIOA, &GPIO_InitStructure);


#define SW_DEBOUDE_TIME     200
#define UP_LIMIT            50
#define DOWN_LIMIT          10


void SysTick_Handler(void);
uint64_t GetTickCount(void);
bool CheckTick(uint64_t TickBase, const uint64_t Time);

void LedInit(void);
void SetFrequency(uint16_t iFre);
uint16_t GetFrequency (void);
void LedProcess(void);



#if 0
bool StrCmp(uint8_t *str1, uint8_t *str2, uint8_t len);

// chuyen doi tu hex sang ascii
uint8_t htoa(uint8_t d);
// chuyen doi tu ascii sang hex
uint8_t atoh(uint8_t c);
uint8_t ByteToStr(uint8_t *str, uint8_t byte);
uint8_t StrToByte(uint8_t *str);
uint8_t WordToStr(uint32_t i, uint8_t *str);
uint16_t StrToWord(uint8_t *str);
uint8_t IntToStr(uint32_t i, uint8_t *str);
uint32_t StrToInt(uint8_t *str);
#endif
#endif

#endif
// end of file

